package com.acme.bankapp.service.bank;

import com.acme.bankapp.domian.bank.*;

public class BankService {

    public static Client createNewClient(double amount,  Gender gender, String name ){
        return new Client(new SavingAccount(amount), gender, name);
    }

    public static Client createNewClientWithCheckingAccount(double amount, double overdraft, Gender gender, String name){
        return new Client(new CheckingAccount(amount, overdraft), gender, name);
    }

    public static void addClient (Bank bank, Client client){
        bank.addClient(client);
    }

    public static void printMaximumAmountToWithdraw(Bank bank){
        Client [] clients = bank.getClients();
        for (int i = 0; i < clients.length; i++){
            System.out.println(clients[i].getGender().appeal() +
                               clients[i].getName() +
                               " maximum amount to withdraw is " +
                               clients[i].getAccount().maximumAmountToWithdraw());
        }
    }

    static void printBalance(Bank bank){
        Client [] clients = bank.getClients();
        for (int i = 0; i < clients.length; i++){
            Account account = clients[i].getAccount();
            System.out.println(i + ": " + account.getBalance());
        }
    }

    public void modifyBank(Bank bank, int [] clients_id, int [] amount){
        Client [] clients = bank.getClients();
        for (int i = 0; i < clients_id.length; i++){
            if (amount[i] >= 0){
                clients[clients_id[i]].getAccount().deposit(amount[i]);
            }else{
                clients[clients_id[i]].getAccount().withdraw(amount[i]);
            }
        }
    }
}
